package com.zhiyou.app.shop.manager.dao.impl;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import com.zhiyou.app.shop.manager.dao.IShopDao;
import com.zhiyou.app.shop.manager.dao.pojo.Goods;
import com.zhiyou.app.shop.manager.dao.pojo.Shop;

@Repository
public class ShopDaoImpl extends BaseHibernateDAO<Shop, String> implements IShopDao {

	public ShopDaoImpl() {
		super(Shop.class);
	}

	public int getMaxOrderNumber() {
		String hql = "select max(orderNumber) from Shop";
		Query query = this.getSession().createQuery(hql);
		Object obj = query.uniqueResult();
		if(null != obj){
			return Integer.valueOf(obj.toString());
		}
		return 0;
	}
	
	public void openOrCloseShop(String ids, boolean isDelete) {
		String hql = "update "+Shop.class.getName()+" set isDelete=:isDelete" +
				" where id in ("+ids+")";
		Query query = getSession().createQuery(hql);
		query.setBoolean("isDelete", isDelete);
		query.executeUpdate();
		
	}

}
